package cmd

import (
	"github.com/spf13/cobra"
)

var (
	shopUrl   string // 门店url
	shopsFile string // 门店列表文件
)

func init() {
	rootCmd.AddCommand(shopCmd)
	shopCmd.Flags().StringVarP(&shopUrl, "url", "U", "", "门店url")
	shopCmd.Flags().StringVarP(&shopsFile, "file", "F", "", "门店列表文件")
}

var shopCmd = &cobra.Command{
	Use:              string(Shop),
	Short:            "Read informations of shop",
	Long:             `Read informations of shop`,
	TraverseChildren: true,
	Run: func(cmd *cobra.Command, args []string) {
		slog.Debugf("shopUrl => %s", shopUrl)
		slog.Debugf("shopsFile => %s", shopsFile)

		NewRunner().
			LoadCredentialFromFile().
			// NavigateWithReferer(`https://www.dianping.com/shop/k7M9KlVJp8xm9BOo`, "https://www.dianping.com/search/keyword/1/0_牛太叔").
			// ScreenshotShopInfo().
			FetchShops(shopUrl, shopsFile).
			// DumpShopInfo().
			// ShopReset().
			// IterShop(func(tr *TaskRunner) {
			// 	tr.ScreenshotShopInfo().
			// 		DumpShopInfo().
			// 		ShopReset().
			// 		Wait(5)
			// }).
			Run()
	},
}
